import React, { Suspense } from 'react'
import { BrowserRouter,Route,Routes,Navigate } from 'react-router-dom'
import routes from './router'
function App() {
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
  const homeRenders = (arr:any) => {
    // eslint-disable-next-line @typescript-eslint/no-explicit-any
    return arr && arr.map((item:any,index:any) => {
      return <Route key={index} path={item.path}
      element={item.element ? <item.element></item.element> : <Navigate to={item.to}></Navigate>} 
      >
        {
          item.children && homeRenders(item.children)
        }

      </Route>
    })
  }
  return (
    <div>
      <Suspense fallback={<div>路由加载中。。。</div>}>
        <BrowserRouter>
           <Routes>
          {
            homeRenders(routes)
          }
        </Routes>
        </BrowserRouter>
       
      </Suspense>
    </div>
  )
}

export default App